﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Windows.Forms;
using biaoqian.CSwnjian;
using FastReport;
using FastReport.Data;
using Kingdee.BOS.WebApi.Client;
using Kingdee.BOS.WebApi.DataEntify;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ProgressBar;

namespace biaoqian
{
    public partial class Baobiao : Form
    {
        public Baobiao()
        {
            InitializeComponent();
        }
        Class1 one = new Class1();
        BiaoQian BQ = new BiaoQian();
        private void Form3_Load(object sender, EventArgs e)
        {
            DataTable dataTable1 = one.Wuliao();
            var id = applisj.values;
            var shu = applisj.IDs;
            DataTable dataTable2 =BQ.NewM(id, ref shu);//返回需要打印的标签信息
                                                     //------------------------------------------------------------
            List<List<object>> BiasoR = BQ.NewMethod();//返回物料的对饮大小标签
            var FE = BiasoR[0][0].ToString();
            var FES = BiasoR[1][0].ToString();
            var path = "";//打开的标签
                          //再分辨物料的大小标签
            path = BQ.biaoqinazhi(dataTable2, FE, FES, path);
            dataTable1 = BQ.Wuliaos(dataTable2);//返回的数据
            DataRow rows = dataTable1.Rows[0];
            DataRow row = dataTable2.Rows[0];
            string lai = Convert.ToString(rows["GM_PART_NUM"]);
            var ling = Convert.ToInt16(rows["QTY"]);
            int sdk;
            string s = row["quantity"].ToString();
            int d = s == "" ? 1 : Convert.ToInt16(row["quantity"]);
            sdk = ling == 0 ? 0 : d / Convert.ToInt16(rows["QTY"]);
            rows["COUNTRY_ORIGIN_DW"] = sdk;//打印次数
            DataSet da = new DataSet();
            da.Tables.Add(dataTable1);
            dataTable1.TableName = "Table1";
            //防伪码
            string baseDirectory1 = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
            string physicalPath1 = Path.Combine(baseDirectory1, "Fastreport\\ProductAntiFake.frx");
            Report report1 = new Report();
            report1.Load(physicalPath1);//打开文件/*
            report1.RegisterData(da);//绑定数据源
                                     //webReport.Report.SetParameterValue("ksnfjidn", Appbian);//替换fastreport参数的值--
            DataBand data1 = report1.Report.FindObject("Data1") as DataBand;
            data1.DataSource = report1.Report.GetDataSource("Table1");
            report1.Prepare();
            report1.ShowPrepared();

            //标签码
            string baseDirectory = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
            string physicalPath = Path.Combine(baseDirectory, path);
            Report report = new Report();
            report.Load(physicalPath);//打开文件/*
            report.RegisterData(da);//绑定数据源
                                    //webReport.Report.SetParameterValue("ksnfjidn", Appbian);//替换fastreport参数的值--
            DataBand data = report.Report.FindObject("Data1") as DataBand;
            data.DataSource = report.Report.GetDataSource("Table1");
            report.Prepare();
            report.ShowPrepared();
        }

    }
}
